import 'package:flutter/material.dart';
import 'package:v50art/AppStyle.dart';
import 'package:v50art/UserApi.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});
  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String count = "0";
  List<String> list = ["用户", "新闻公告", "运维"];
  @override
  void initState() {
    super.initState();
    UserApi.getUserCount().then((value) {
      setState(() {
        count = value;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Theme.of(context).colorScheme.inversePrimary,
          title: const Text("管理"),
        ),
        body: Column(
          children: [ 
            Text("用户数量:$count"),
            Expanded(
              child: Padding(
                padding: const EdgeInsets.symmetric(horizontal: 10),
                child: GridView.builder(
                    shrinkWrap: true,
                    gridDelegate:
                        const SliverGridDelegateWithFixedCrossAxisCount(
                            crossAxisCount: 2,
                            crossAxisSpacing: 10,
                            mainAxisSpacing: 20,
                            childAspectRatio: 1.5),
                    itemCount: 100,
                    itemBuilder: (BuildContext context, int index) {
                      return Container(
                        decoration: BoxDecoration(
                            borderRadius: AppStyle.borderRadius,
                            color:
                                Theme.of(context).colorScheme.inversePrimary),
                        child: const Center(
                          child: Text("tffgbhmoklvgyhjk"),
                        ),
                      );
                    }),
              ),
            )
          ],
        ));
  }
}
